package com.example.demo.java8.day1;


import com.example.demo.java8.Employee;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;


public class Test1 {
    List<Employee> emps = Arrays.asList(
            new Employee(102, "李四", 59, 6666.66, Employee.Status.BUSY),
            new Employee(101, "张三", 18, 9999.99, Employee.Status.FREE),
            new Employee(103, "王五", 28, 3333.33, Employee.Status.VOCATION),
            new Employee(104, "赵六", 8, 7777.77, Employee.Status.BUSY),
            new Employee(104, "赵六", 2, 7777.77, Employee.Status.FREE),
            new Employee(104, "赵六", 1, 7777.77, Employee.Status.FREE),
            new Employee(105, "田七", 38, 5555.55, Employee.Status.BUSY)
    );

    @Test
    public void test1(){
        emps.stream()
            .sorted((e1,e2)->{
                if(e1.getName().equals(e2.getName())){
                    return Integer.compare(e2.getAge(),e1.getAge());
                }else{
                    return e2.getName().compareTo(e1.getName());
                }
            }).forEach(System.out::println);
    }



 public void  happy(Double aa,Consumer<Double> bb){
     bb.accept(aa);
 }

}
